Skip to content

fix(gradle/plugin): reset kotlin SourceDirectorySet classesDirectory - #1926

Open
guilhas07 wants to merge 1 commit into
raphw:masterfrom
guilhas07:fix-kotlin
Open

fix(gradle/plugin): reset kotlin SourceDirectorySet classesDirectory#1926
guilhas07 wants to merge 1 commit into
raphw:masterfrom
guilhas07:fix-kotlin

Conversation

@guilhas07

@guilhas07 guilhas07 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Problem:

Kotlin Gradle Plugin binds SourceDirectorySet classesDirectory to compileKotlin.destinationDirectory via SDS.compiledBy(compileKotlin, ::destinationDirectory). The JVM jar task consumes:

  • sourceSet.output.classesDirs, which tracks SDS.destinationDirectory (kotlin/main)
  • SDS.classesDirectory, which tracks compileKotlin.destinationDirectory (overwritten by byteBuddyKotlin to kotlinByteBuddyRaw). source

This results in the jar having duplicated entries for every kotlin class.

Solution:

Reset SDS.classesDirectory from compileKotlin.destinationDirectory to byteBuddyKotlin.target (kotlin/main).


I believe I've missed this before because I had duplicatesStrategy = EXCLUDE on the jar task (a leftover from when I tried to create the task "by hand"), which silently dropped the duplicate entries and hid this bug.

Problem: Kotlin Gradle Plugin binds SourceDirectorySet classesDirectory
to compileKotlin.destinationDirectory via `SDS.compiledBy(compileKotlin,
::destinationDirectory)`.

The JVM jar task consumes:
  - sourceSet.output.classesDirs, which tracks SDS.destinationDirectory (kotlin/main)
  - SDS.classesDirectory, which tracks compileKotlin.destinationDirectory
  (overwritten by byteBuddyKotlin to kotlinByteBuddyRaw).

This results in the jar having duplicated entries for every kotlin
class.

Solution: Reset SDS.classesDirectory from compileKotlin.destinationDirectory
to byteBuddyKotlin.target (kotlin/main).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant